package com.wxy.xr.service.impl;

import com.wxy.xr.dao.BaseDao;
import com.wxy.xr.service.BaseService;
import java.util.List;

public abstract class BaseServiceImpl<T> implements BaseService<T> {
    protected BaseDao<T> dao=newDao();
    protected BaseDao<T> newDao() {
        try {
            String clsName = getClass().getName()
                    .replace(".service.", ".dao.")
                    .replace("Service", "Dao");
            return (BaseDao<T>) Class.forName(clsName).newInstance();
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }
    }
    public boolean remove(Integer id){
        return dao.remove(id);
    }
    public boolean remove(List<Integer> ids) {
        return dao.remove(ids);
    }
        /**
        * 添加或更新
        * @return
        */
    public boolean save(T bean){
        return dao.save(bean);
    }

    /**
     *获取单个对象
     * @param id
     * @return
     */
    public T get(Integer id){
        return null;
    }

    /**
     * 获取多个对象
     * @return
     */
    public List<T> list(){
        return dao.list();
    }

    /**
     * 获取统计值
     * @return
     */
    public int count() {
        return 0;
    }
}
